/*
 * GwtYuiCarousel - API to integrate YUI Carousel in GWT framework
 *
 * Copyright (c) 2007, Nicolas Hoppenot
 *
 * This free software is licensed under the Apache License, Version 2.0 (the "License").
 * To obtain a copy of the licence, visit : http://www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed WITHOUT ANY WARRANTY OR CONDITION OF ANY KIND.
 * Please see the license for more information.
 *
 * Version $0.6.1-beta1$
 */
package com.gwtyuicarousel.spotlight.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.gwtyuicarousel.client.ui.CarouselConfig;
import com.gwtyuicarousel.client.ui.Carousel.AnimationMethod;

/**
 * This is the rewritting of the Bill W. Scott's Yui Carousel sample "Spotlight & Preview" with
 * using GwtYuiCarousel APIs. Cf. http://billwscott.com/carousel/carousel_spotlight.html
 * 
 * @version $0.6.1-beta1$
 * @author Nicolas Hoppenot
 * 
 */
public class SpotLight implements EntryPoint {

  /**
   * Default constructor
   */
  public SpotLight() {
    super();
  }

  /**
   * When the module is loaded, we create the Yui Carousel "Spotlight & Preview" example.
   * 
   * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
   */
  public void onModuleLoad() {
    // Creation of the previous control Element
    Image prevImage = new Image("resources/images/left-enabled.gif");
    prevImage.setTitle("Previous Button");
    DOM.setElementAttribute(prevImage.getElement(), "id", "prev-arrow");
    DOM.setElementProperty(prevImage.getElement(), "className", "left-button-image");
    // Creation of the next control Element
    Image nextImage = new Image("resources/images/right-enabled.gif");
    nextImage.setTitle("Next Button");
    DOM.setElementAttribute(nextImage.getElement(), "id", "next-arrow");
    DOM.setElementProperty(nextImage.getElement(), "className", "right-button-image");
 // Instanciate the carousel widget
    SpotLightStructure carousel = new SpotLightStructure("carousel_spotlight", nextImage,
        prevImage, true, getCarouselConfig());
    RootPanel.get().add(carousel);
  }

  /**
   * Construct the carousel configuration object
   * 
   * @return The carousel configuration object
   */
  private CarouselConfig getCarouselConfig() {
    CarouselConfig config = new CarouselConfig();
    config.setNumVisible(5);
    config.setAnimationSpeed(600);
    config.setAnimationMethod(AnimationMethod.BACK_BOTH);
    config.setScrollInc(1);
    config.setScrollBeforeAmount(2);
    config.setFirstVisible(-2);
    config.setSize(15);
    config.setScrollAfterAmount(2);
    config.setNavMargin(40);
    return config;
  }

}
